<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue中多个元素或组件的过度</title>
    <style>
        .v-enter, v-leave-to {
            opacity: 0;
        }

        .v-enter-active,.v-leave-active {
            transition: opacity 1s;
        }
    </style>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <!-- mode指定效果  这里先隐藏再显示 transition-group上没有name属性，则类class前缀已v-开头，否则以name名开头 -->
        <transition-group mode="out-in">
            <div v-for="item of list" key="item.id">
                {{item.title}}
            </div>
        </transition-group>

        <button @click="handleBtnClick">Add</button>
    </div>
    <script>
        var count = 0

        new Vue({
            el : "#app",
            data : {
                list : []
            },
            methods : {
                handleBtnClick : function () {
                    this.list.push({
                        id : ++count,
                        title : 'Hello World'
                    })
                }
            }
        })
    </script>
</body>
</html>